<template>
  <div class="intervention">
    <el-container>
      <el-input
        style="width: 20%"
        placeholder="预约档案号/姓名"
        v-model="parameter.content"
        clearable
      ></el-input>
      <el-button
        type="primary"
        size="mini"
        @click="onSubmit"
        icon="el-icon-search"
        round
        >查询</el-button
      >
    </el-container>
    <el-container>
      <el-button
        type="success"
        size="mini"
        icon="el-icon-circle-plus"
        @click.native="addChaselectAllTQuestion()"
        round
        >添加</el-button
      >
    </el-container>
    <el-table style="width: 100%" align="center"
      v-loading="loading"
      element-loading-text="拼命加载中"
      element-loading-spinner="el-icon-loading"
     :data="AllUser">
      <el-table-column label="预约档案号" prop="tfollowtmerber" width="120">
      </el-table-column>
      <el-table-column label="姓名" prop="tfollowname" width="100">
      </el-table-column>
      <el-table-column label="回访日期" prop="tFollowdate" width="100">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top">
            <p>回访日期:{{scope.row.tFollowdate}}</p>
              <div slot="reference" class="name-wrapper">
                  <el-tag size="medium">{{ scope.row.tFollowdate }}</el-tag>
              </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column label="回访人员" prop="tfollowconfirmcaller" width="100">
        <template slot-scope="scope">
          <span v-if="scope.row.tfollowconfirmcaller == null"> 初始化跟随</span>
          <span v-if="scope.row.tfollowconfirmcaller != null">
            {{ scope.row.tfollowconfirmcaller }}</span>
        </template>
      </el-table-column>
      <el-table-column label="方式" prop="tmanner" width="100">
        <template slot-scope="scope">
          <span v-if="scope.row.tmanner == null"> 初始化跟随</span>
          <span v-if="scope.row.tmanner != null"> {{ scope.row.tmanner }}</span>
        </template>
      </el-table-column>
      <el-table-column label="回访内容" prop="tfollowcontent" width="100">
        <template slot-scope="scope">
           <el-popover trigger="hover" placement="top">
            <p>回访内容:
               <span v-if="scope.row.tfollowcontent == null"> 初始化跟随</span>
               <span v-if="scope.row.tfollowcontent != null">{{ scope.row.tfollowcontent }}</span>
              </p>
              <div slot="reference" class="name-wrapper">
                  <el-tag size="medium">
                     <span v-if="scope.row.tfollowcontent == null"> 初始化跟随</span>
                     <span v-if="scope.row.tfollowcontent != null">{{ scope.row.tfollowcontent }}</span>
                  </el-tag>
              </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column label="反馈信息" prop="tfollowfeedback" width="100">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top">
              <p>反馈信息:
                <span v-if="scope.row.tfollowfeedback == null"> 初始化跟随</span>
                <span v-if="scope.row.tfollowfeedback != null">{{ scope.row.tfollowfeedback }}</span>
              </p>
                <div slot="reference" class="name-wrapper">
                    <el-tag size="medium">
                      <span v-if="scope.row.tfollowfeedback == null"> 初始化跟随</span>
                      <span v-if="scope.row.tfollowfeedback != null">{{ scope.row.tfollowfeedback }}</span>
                    </el-tag>
                </div>
            </el-popover>
        </template>
      </el-table-column>
      <el-table-column label="处理结果" prop="tresult" width="100">
        <template slot-scope="scope">
          <span v-if="scope.row.tresult == 0"> 未痊愈 </span>
          <span v-if="scope.row.tresult == 1"> 痊愈 </span>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="350">
        <template slot-scope="scope">
          <el-button
          round
            size="mini"
            type="primary"
            plain
            v-if="scope.row.tresult == 0"
            @click.native="update(scope.row)"
            icon="el-icon-edit"
          >
            改变干预计划
          </el-button>
          <el-button
          round
            type="danger"
            size="mini"
            @click.native="deleteRow(scope.row,scope.$index, AllUser)"
            icon="el-icon-delete"
          >
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page.sync="parameter.page"
      :page-sizes="[2, 5, 10, 20]"
      :pager-count="9"
      background
      :page-size.sync="parameter.num"
      layout="total, sizes, prev, pager, next, jumper"
    >
    </el-pagination>
    <el-dialog title="添加随访" :visible.sync="dialogFormVisible">
      <el-tabs type="border-card">
        <el-tab-pane label="随访信息">
          <el-form label-width="80px" :model="addInterventBean" :rules="rules" ref="ruleForm">
            <el-row>
              <el-col :span="12">
                <el-form-item label="被干预人" prop="name">
                  <el-input
                    v-model="addInterventBean.name"
                    size="small"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="预约号" prop="termer">
                  <el-input
                    v-model="addInterventBean.termer"
                    size="small"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="方式" prop="value">
                  <el-select
                    v-model="addInterventBean.value"
                    placeholder="请选择"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="时间">
                  <el-date-picker
                    v-model="addInterventBean.Date1"
                    type="datetime"
                    :disabled="true"
                  >
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
            <el-form-item label="随访内容">
              <el-input
                type="textarea"
                v-model="addInterventBean.Content"
              ></el-input>
            </el-form-item>
            <el-form-item label="反馈信息">
              <el-input
                type="textarea"
                v-model="addInterventBean.feedback"
              ></el-input>
            </el-form-item>
            <el-form-item label="处理结果">
              <el-row>
                <el-col :span="8">
                  <el-select
                    v-model="addInterventBean.tresult"
                    placeholder="请选择"
                  >
                    <el-option
                      v-for="item in options2"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    >
                    </el-option>
                  </el-select>
                </el-col>
                <el-col :span="16">
                  <input type="hidden" />
                </el-col>
              </el-row>
            </el-form-item>
          </el-form>
        </el-tab-pane>
        <el-tab-pane label="附件">
            

            <el-form>
    <el-form-item>
      <el-upload
        class="upload-demo"
        ref="upload"
        action=""
        :http-request="upload"
        :before-upload="beforeAvatarUpload"
        multiple=""
        :auto-upload="false"
        list-type="picture-card"
         :file-list="fileList"
      >
        <i slot="default" class="el-icon-plus"></i>
    <div slot="file" slot-scope="{file}">
      <img
        class="el-upload-list__item-thumbnail"
        :src="file.url" alt=""
      >
      <span class="el-upload-list__item-actions">
        <span
          class="el-upload-list__item-preview"
          @click="handlePictureCardPreview(file)"
        >
          <i class="el-icon-zoom-in"></i>
        </span>
        <span
          v-if="!disabled"
          class="el-upload-list__item-delete"
          @click="handleDownload(file)"
        >
          <i class="el-icon-download"></i>
        </span>
        <span
          v-if="!disabled"
          class="el-upload-list__item-delete"
          @click="handleRemove(file)"
        >
          <i class="el-icon-delete"></i>
        </span>
      </span>
    </div>
          </el-upload>
    </el-form-item>
  </el-form>
  <el-button
          style="margin-left: 10px"
          size="small"
          type="success"
          @click="submitUpload"
          >上传到服务器</el-button
        >
        </el-tab-pane>
      </el-tabs>

      <div style="margin-top: -20px" slot="footer" class="dialog-footer">
        <el-button round @click="dialogFormVisible = false">取 消</el-button>
        <el-button round type="primary" @click="tijiao()">确 定</el-button>

      </div>
    </el-dialog>
    <el-dialog title="修改制定方案" :visible.sync="dialogFormVisible2">
      <template>
        <el-tabs v-model="activeName2" type="card" @tab-click="handleClick2">
          <el-tab-pane label="基本信息" name="first2">
            <div style="min-height: 350px">
              <div class="option">
                <div class="left">
                  <div class="title">档案号</div>
                  <div class="content">
                    <span>{{ user.tmerber }}</span>
                  </div>
                </div>
                <div class="right">
                  <div class="title">姓名</div>
                  <div class="content">
                    <span>{{ user.name }}</span>
                  </div>
                </div>
              </div>
              <div class="option">
                <div class="left">
                  <div class="title">方案标题</div>
                  <div class="content">
                    <el-input v-model="input" :disabled="true"> </el-input>
                  </div>
                </div>
                <div class="right">
                  <div class="title">选用模板</div>
                  <div class="content">
                    <template>
                      <el-select
                        v-model="value"
                        clearable
                        placeholder="请选择"
                        @change="selectption(value)"
                      >
                        <el-option
                          v-for="item in options3"
                          :key="item.ttemplateid"
                          :label="item.keywords"
                          :value="item"
                        >
                        </el-option>
                      </el-select>
                    </template>
                  </div>
                </div>
              </div>
              <div class="option">
                <div class="left">
                  <div class="title">开始时间</div>
                  <div class="content">
                    <el-date-picker
                      type="date"
                      placeholder="选择日期"
                      v-model="createDate"
                    >
                    </el-date-picker>
                  </div>
                </div>
                <div class="right">
                  <div class="title">结束时间</div>
                  <div class="content">
                    <el-date-picker
                      type="date"
                      v-model="endDate"
                      placeholder="选择日期"
                    >
                    </el-date-picker>
                  </div>
                </div>
              </div>
              <div class="textarea">
                <div class="title">方案目标</div>
                <textarea v-model="texta" :disabled="true"> </textarea>
              </div>
              <div class="Text">
                <div>执行人</div>
                <div>张三</div>
              </div>
            </div>
            <div class="but">
              <el-button>取 消</el-button>
              <el-button type="primary" @click="save()">保存</el-button>
            </div>
          </el-tab-pane>
          <el-tab-pane label="饮食干预" name="third2">
            <el-container>
              <el-input
                style="width: 20%"
                placeholder="编号/名称"
                v-model="parameter2.content"
                clearable
              ></el-input>
              <el-button
                type="primary"
                size="mini"
                @click="onSubmitTMeals"
                icon="el-icon-search"
                round
                >查询</el-button
              >
            </el-container>
            <el-table
              style="width: 100%"
              align="center"
              :data="AllTMeals"
              ref="zttable"
              @selection-change="handleSelectionTMealsChange"
            >
              <el-table-column
                type="selection"
                width="55"
                :selectable="selectable"
              >
              </el-table-column>
              <el-table-column label="编号" prop="code" width="120">
              </el-table-column>
              <el-table-column label="名称" prop="name" width="120">
              </el-table-column>
              <el-table-column label="类别" prop="tmealsType.name" width="120">
              </el-table-column>
              <el-table-column label="食品说明" prop="explain" width="120">
              </el-table-column>
            </el-table>
            <el-pagination
              :total="total1"
              @size-change="handleSizeChange1"
              @current-change="handleCurrentChange1"
              :current-page.sync="parameter2.page"
              :page-sizes="[2, 5, 10, 20]"
              :pager-count="9"
              background
              :page-size.sync="parameter2.num"
              layout="total, sizes, prev, pager, next, jumper"
            >
            </el-pagination>
          </el-tab-pane>

          <el-tab-pane label="运动干预" name="second2">
            <el-container>
              <el-input
                style="width: 20%"
                placeholder="编号/名称"
                v-model="parameter3.content"
                clearable
              ></el-input>
              <el-button
                type="primary"
                size="mini"
                @click="onSubmittMentality"
                icon="el-icon-search"
                round
                >查询</el-button
              >
            </el-container>
            <el-table
              style="width: 100%"
              align="center"
              :data="AllTSportsItem"
              ref="zttable2"
              @selection-change="handleSelectionTSportsItemChange"
            >
              <el-table-column
                type="selection"
                width="55"
                :selectable="selectable"
              >
              </el-table-column>
              <el-table-column label="编号" prop="code" width="120">
              </el-table-column>
              <el-table-column label="名称" prop="name" width="120">
              </el-table-column>
              <el-table-column label="项目强度" prop="strength" width="120">
              </el-table-column>
              <el-table-column label="注意事项" prop="notes" width="120">
              </el-table-column>
            </el-table>
            <el-pagination
              :total="total2"
              @size-change="handleSizeChange2"
              @current-change="handleCurrentChange2"
              :current-page.sync="parameter3.page"
              :page-sizes="[2, 5, 10, 20]"
              :pager-count="9"
              background
              :page-size.sync="parameter3.num"
              layout="total, sizes, prev, pager, next, jumper"
            >
            </el-pagination>
          </el-tab-pane>
        </el-tabs>
      </template>
    </el-dialog>
  </div>
</template>

<script>
import Vue from "vue";
import axios from "axios";
export default Vue.extend({
  data() {
    return {
          rules: {
          name: [
            { required: true, message: '请输入活动名称', trigger: 'blur' },
            { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
          ],
          termer: [
          { required: true, message: '请输入档案号', trigger: 'blur' },
          ],
           value: [
            { required: true, message: '请选择活动区域', trigger: 'change' }
          ],
          },
      loading: true,
      dialogFormVisible: false,
      dialogFormVisible2: false,
      tdiettemplateselecteds: [],
      tmovingtemplateselections: [],
      multipleSelection1: [],
      multipleSelection2: [],
      texta: "",
        disabled: false,
      fileList:[],
      createDate: "",
      endDate: "",
      AllUser: [],
      options3: [],
      parameter: {
        page: 1,
        num: 5,
        content: "",
      },
      total: 0,
      options2: [
        {
          value: "1",
          label: "好转",
        },
        {
          value: "0",
          label: "未好转",
        },
      ],
      options: [
        {
          value: "电话",
          label: "电话",
        },
        {
          value: "邮箱",
          label: "邮箱",
        },
        {
          value: "短信",
          label: "短信",
        },
      ],
      addInterventBean: {
        value: "",
        value1:[],
        name: "",
        termer: "",
        Date1: "",
        Content: "",
        feedback: "",
        tresult: 1 + "",
        ConfirmCaller: "",
      },
      AllTSportsItem: [],
      input: "",
      AllTMeals: [],
      activeName2: "first2",
      nnnn:"",
      user: {
        name: "",
        tmerber: "",
      },
      parameter2: {
        page: 1,
        num: 5,
        content: "",
      },
      parameter3: {
        page: 1,
        num: 5,
        content: "",
      },
      total1: 0,
      total2: 0,
      value: "",
      listInqu: [],
      selectInqu: [],
    };
  },
  methods: {

    handlePictureCardPreview(file) {
        this.dialogImageUrl = file.url;
        this.dialogVisible = true;
      },
        beforeAvatarUpload(file) {
        const isLt2M = file.size / 1024 / 1024 < 2;
        if (!isLt2M) {
          this.$message.error('大小不能超过 2MB!');
        }
        return isLt2M;
      },
      submitUpload() {
      this.$refs.upload.submit();
    },
    //通过onchanne触发方法获得文件列表
    handleChange(file, fileList) {
      this.fileList = fileList;
      console.log(fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
    upload(file) {
      let fd = new FormData();

      //文件信息中raw才是真的文件
     
      fd.append("files", file.file);
     fd.append("id", this.ss);
      fd.append("mtid", this.mtid);
      console.log(fd);
      console.log(this.ss)

      axios.post("/api/FileLoad/up",fd).then((res) => {
        this.url = res.data;
       
        this.$notify({
          title: '成功',
          message: '文件上传',
          type: 'success'
        });
      
        
      });
       this.dialogFormVisible = false
    },
     handleRemove(file) {
        this.$refs.upload.handleRemove(file); 

      },
    
     resetForm() {
        this.$refs.ruleForm.resetFields();
      },
            //根据档案号去查找人群分类里面是否含有本档案号
    deleteRow(scope,index,allList){
      let id=scope.tfollowtmerber;
          this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          allList.splice(index,1)
           //回访表的数据
          axios.post("/api/lqHealth/deletefwDlBytermer",{tmerber:id}).then(res=>{
            console.log(res.data)
          })
          if(allList.length==0){
            this.parameter.page+=1
            this.load()
          }
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        }) 
    },
    //保存数据
    save() {
      if (this.value != "") {
        if (this.createDate != "" && this.endDate != "") {
          if (
            1==1
          ) {
            this.item = this.value1;
            axios
              .post("/api/lqHealth/updateInterventionprogrammes", {
                tmerber: this.user.tmerber,
                name: this.user.name,
                t_Manage_templateId: this.item.ttemplateid,
                createDate: this.createDate,
                endDate: this.endDate,
              })
              .then((res) => {
                if (res.data > 0) {
                  this.$message({
                    type: "success",
                    message: "选用模板修改成功",
                  });
                  this.dialogFormVisible2=false
                } else {
                  this.$message({
                    type: "error",
                    message: "用户制定了计划 或 用户正在使用干预计划",
                  });
                }
              });
          } else {
            this.$message({
              type: "error",
              message: "时间不可以小于当前时间!",
            });
          }
        } else {
          this.$message({
            type: "error",
            message: "请将时间数据填写完成!",
          });
        }
      } else {
        if (this.createDate != "" && this.endDate != "") {
          if (
           1==1
          ) {
            this.item = this.value1;
            let aa = [];
            let bb = [];
            this.multipleSelection1.forEach((element) => {
              aa.push(element.code);
            });
            this.multipleSelection2.forEach((element) => {
              bb.push(element.code);
            });
            axios
              .post("/api/lqHealth/updateInterventionprogrammes", {
                tmerber: this.user.tmerber,
                t_indeit_scode: JSON.stringify(aa),
                name:  this.user.name,
                t_inmoving_code: JSON.stringify(bb),
                createDate: this.createDate,
                endDate: this.endDate,
              })
              .then((res) => {
                if (res.data > 0) {
                  this.$message({
                    type: "success",
                    message: "自定义修改制定成功",
                  });
                  this.dialogFormVisible2=false
                } else {
                  this.$message({
                    type: "error",
                    message: "用户制定了计划 或 用户正在使用干预计划",
                  });
                }
              });
          } else {
            this.$message({
              type: "error",
              message: "时间不可以小于当前时间!",
            });
          }
        } else {
          this.$message({
            type: "error",
            message: "请将时间数据填写完成!",
          });
        }
      }
    },
    isOK() {
      if (this.addInterventBean.name == "") {
        this.$message({
          type: "error",
          message: "被干预人未填写!",
        });
        return false;
      }
      if (this.addInterventBean.termer == "") {
        this.$message({
          type: "error",
          message: "被干预人编号未填写!",
        });
        return false;
      }
      if (this.addInterventBean.value == "") {
        this.$message({
          type: "error",
          message: "反式未选择!",
        });
        return false;
      }
      if (this.addInterventBean.Content == "") {
        this.$message({
          type: "error",
          message: "访问内容未填写!",
        });
        return false;
      }
      if (this.addInterventBean.feedback == "") {
        this.$message({
          type: "error",
          message: "反馈信息未填写!",
        });
        return false;
      }
      if (this.addInterventBean.tresult == "1") {
        var a = confirm("你确定客户已经有好转迹象嘛");
        if (!a) {
          return false;
        }
      }
      return true;
    },
    tijiao() {
  this.$refs.ruleForm.validate((valid) => {
          if (valid) {
            if (this.isOK()) {
        axios
          .post("/api/lqHealth/selectIntervenByInqiereaBy", {
            name: this.addInterventBean.name,
            termer: this.addInterventBean.termer,
            Date1: this.addInterventBean.Date1,
          })
          .then((res) => {
            if (res.data == 0) {
              this.$message({
                type: "error",
                message: "用户或者编号错误请重新确认!",
              });
            }
            if (res.data == 1) {
              this.$message({
                type: "error",
                message: "用户制定方案已过期!",
              });
            }
            if (res.data > 1) {
              axios
                .post("/api/lqHealth/addfollw", {
                  manner: this.addInterventBean.value,
                  name: this.addInterventBean.name,
                  termer: this.addInterventBean.termer,
                  Date1: this.addInterventBean.Date1,
                  Content: this.addInterventBean.Content,
                  feedback: this.addInterventBean.feedback,
                  tresult: this.addInterventBean.tresult,
                  ConfirmCaller: this.parameter.janID,
                })
                .then((res1) => {
                  if (res1.data > 0) {
                    this.$message({
                      type: "success",
                      message: "添加随访成功!",
                    });
                    this.dialogFormVisible = false;
                    this.load();
                  }
                });
            }
          });
      }
          } else {
            console.log('error submit!!');
            return false;
          }
        });
     
      
    },
    //选择模板改变
    selectption(scope) {
      this.input = scope ? scope.ttitle : "";
      this.texta = scope ? scope.ttarget : "";
      this.tdiettemplateselecteds = scope ? scope.tdiettemplateselecteds : [];
      this.tmovingtemplateselections = scope
        ? scope.tmovingtemplateselections
        : [];
              this.value = scope?scope.keywords:'';
      this.value1=scope?scope:[];
    },
    addChaselectAllTQuestion() {
      this.dialogFormVisible = true;
      this.Date();
    },
    handleSizeChange() {
      this.load();
    },
    handleCurrentChange() {
      this.load();
    },
    onSubmit() {
      this.load();
    },
    update(Scope) {
      this.dialogFormVisible2 = true;
      axios
        .post("/api/lqHealth/inquireabouttmetber", {
          tmerber: Scope.tfollowtmerber,
        })
        .then((res) => {
          this.listInqu = res.data;
          this.createDate = this.listInqu[0].createdate;
          this.endDate = this.listInqu[0].enddate;
          this.user.name = this.listInqu[0].tintername;
          this.nnnn=this.listInqu[0].tintername;
          this.user.tmerber = this.listInqu[0].tinterveneMerber;
          if (this.listInqu[0].tmanageTemplateid == null) {
            this.selectInqu = this.listInqu;
          } else {
            //this.value=this.listInqu[0].tmanageTemplateid
            for (let i = 0; i < this.options3.length; i++) {
              if (
                this.options3[i].ttemplateid ==
                this.listInqu[0].tmanageTemplateid
              ) {
                this.value = this.options3[i].keywords;
                this.selectption(this.options3[i]);
              }
            }
          }
        });
    },
    load() {
      
         axios
        .get(
          "/api/TRoleAllList?name=" +
            JSON.parse(sessionStorage.getItem("user")).username
        )
        .then((res) => {
          if (res.data.name == "系统管理员") {
             axios
        .post("/api/lqHealth/selectAllTFollow", this.parameter)
        .then((res) => {
          console.log(res);
          this.AllUser = res.data.list;
          this.parameter.page = res.data.pageNum;
          this.parameter.num = res.data.pageSize;
          this.total = res.data.total;
          axios.get("/api/lqHealth/AllTTemplatemanage").then((res) => {
            this.options3 = res.data;
          });

          //加载样式
        setTimeout(() => {
          this.loading=false;
        }, 1000);
        });
          } else {
                   axios.post("/api/lqHealth/selectThByname",{name: JSON.parse(sessionStorage.getItem("user")).username}).then(rp=>{
             this.parameter.janID=rp.data.healthMgrId
            
            axios
              .post("/api/lqHealth/selectAllTFollow1", this.parameter)
              .then((res) => {
                console.log(res);
                this.AllUser = res.data.list;
                this.parameter.page = res.data.pageNum;
                this.parameter.num = res.data.pageSize;
                this.total = res.data.total;
 axios.get("/api/lqHealth/AllTTemplatemanage").then((res) => {
            this.options3 = res.data;
          });
                //加载样式
                setTimeout(() => {
                  this.loading = false;
                }, 1000);
              });
            })



          }
        });
    },
    success() {
      this.$message({
        type: "success",
        message: "已确认分类信息!",
      });
    },
    Date() {
      const nowDate = new Date();
      const date = {
        year: nowDate.getFullYear(),
        month: nowDate.getMonth() + 1,
        date: nowDate.getDate(),
        hours: nowDate.getHours(),
        minutes: nowDate.getMinutes(),
        seconds: nowDate.getSeconds(),
      };

      const newmonth = date.month > 10 ? date.month : "0" + date.month;
      const newday = date.date > 10 ? date.date : "0" + date.date;
      const newminutes = date.minutes < 10 ? "0" + date.minutes : date.minutes;
      const newseconds = date.seconds < 10 ? "0" + date.seconds : date.seconds;
      this.addInterventBean.Date1 =
        date.year +
        "-" +
        newmonth +
        "-" +
        newday +
        " " +
        date.hours +
        ":" +
        newminutes +
        ":" +
        newseconds;
    },
    selectable() {
      if (this.value != "") {
        return false;
      } else {
        return true;
      }
    },
    //查询所有的模板
    onSubmittMentality() {
      this.selectAllTSportsItem();
    },
    onSubmitTMeals() {
      this.selectAllTMeals();
    },
    handleClick2(tab, event) {
      if (tab.name == "third2") {
        this.selectAllTMeals();
      } else if (tab.name == "second2") {
        this.selectAllTSportsItem();
      }
    },
    handleSelectionTMealsChange(val) {
      this.multipleSelection1 = val;
    },
    handleSelectionTSportsItemChange(val) {
      this.multipleSelection2 = val;
    },
    handleSizeChange1() {
      this.selectAllTMeals();
    },
    handleCurrentChange1() {
      this.selectAllTMeals();
    },
    handleSizeChange2() {
      this.selectAllTSportsItem();
    },
    handleCurrentChange2() {
      this.selectAllTSportsItem();
    },
    //所有的饮食信息并胖断选择
    selectAllTMeals() {
      axios
        .post("/api/lqHealth/selectAllTMeals", this.parameter2)
        .then((res) => {
          this.AllTMeals = res.data.list;
          this.parameter2.page = res.data.pageNum;
          this.parameter2.num = res.data.pageSize;
          this.total1 = res.data.total;
          if (this.value != "") {
            this.$nextTick(() => {
              for (let i = 0; i < this.AllTMeals.length; i++) {
                for (let j = 0; j < this.tdiettemplateselecteds.length; j++) {
                  //两个数组做比对,选中的做勾选
                  if (
                    this.AllTMeals[i].code ==
                    this.tdiettemplateselecteds[j].tdeitScode
                  ) {
                    this.$refs.zttable.toggleRowSelection(this.AllTMeals[i]);
                  }
                }
              }
            });
          } else {
            this.$nextTick(() => {
              for (let i = 0; i < this.AllTMeals.length; i++) {
                for (let j = 0; j < this.selectInqu.length; j++) {
                  //两个数组做比对,选中的做勾选
                  if (
                    this.AllTMeals[i].code == this.selectInqu[j].tindeitScode
                  ) {
                    this.$refs.zttable.toggleRowSelection(this.AllTMeals[i]);
                  }
                }
              }
            });
          }
        });
    },
    //所有的运动信息并胖断选择
    selectAllTSportsItem() {
      axios
        .post("/api/lqHealth/selectAllTSportsItem", this.parameter3)
        .then((res) => {
          this.AllTSportsItem = res.data.list;
          this.parameter3.page = res.data.pageNum;
          this.parameter3.num = res.data.pageSize;
          this.total2 = res.data.total;
          if (this.value != "") {
            this.$nextTick(() => {
              for (let i = 0; i < this.AllTSportsItem.length; i++) {
                for (
                  let j = 0;
                  j < this.tmovingtemplateselections.length;
                  j++
                ) {
                  //两个数组做比对,选中的做勾选
                  if (
                    this.AllTSportsItem[i].code ==
                    this.tmovingtemplateselections[j].tmovingCode
                  ) {
                    this.$refs.zttable2.toggleRowSelection(
                      this.AllTSportsItem[i]
                    );
                  }
                }
              }
            });
          } else {
            this.$nextTick(() => {
              for (let i = 0; i < this.AllTSportsItem.length; i++) {
                for (let j = 0; j < this.selectInqu.length; j++) {
                  //两个数组做比对,选中的做勾选
                  if (
                    this.AllTSportsItem[i].code ==
                    this.selectInqu[j].tinmovingCode
                  ) {
                    this.$refs.zttable2.toggleRowSelection(
                      this.AllTSportsItem[i]
                    );
                  }
                }
              }
            });
          }
        });
    },
  },
  created() {
    this.load();
  },
});
</script>
<style scoped>
.rigth {
  width: 47%;
  height: 100vh;
  background-color: eee;
  text-align: center;
  box-shadow: 0 0 0.1rem;
}
.textarea {
  width: 100%;
  min-height: 100px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
}
.textarea > div {
  width: 100px;
  height: 100px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.textarea > textarea {
  width: calc(75% - 100px);
  min-height: 90px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.271);
  transition: 0.3s;
  outline: none;
  padding: 10px;
}
.textarea > textarea:focus {
  border-color: #409eff;
}
.option {
  margin-top: 10px;
  width: 100%;
  min-height: 50px;
  padding-left: 10px;

  display: flex;
  justify-content: center;
  align-items: center;
}
.option > div {
  width: 50%;
  height: 100%;

  display: flex;
  justify-content: flex-start;
  align-items: center;
}
.option > div .title {
  width: 100px;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.option > div .content {
  width: calc(100% - 100px);

  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding-left: 10px;
}
.but {
  float: right;
  margin-right: 100px;
}
.Text {
  width: 300px;
  float: left;
  display: flex;
  justify-content: space-between;
  margin-left: 30px;
  margin-top: 15px;
}
.Text div:nth-child(2) {
  margin-right: 100px;
}
</style>